import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import nodejs from '@dfeidao/atom-web/msg/nodejs';

import get from '@dfeidao/atom-web/local/get';

export default async function a010(fd: IFeidaoAiBrowserComponent) {
	// todo
	const risk_po_name1 = fd.data.node.querySelector<HTMLInputElement>('[data-fname="risk_po_name"]').value;

	console.log("亿欧元=。", risk_po_name1);

	if (!risk_po_name1) {
		alert('请输入客户名称');
		return;
	}

	const no = get(fd, 'no');
	const zname = get(fd, 'zname') as [{ a: string, b: string }];

	console.log("是多少啊33333=》", no);
	// console.log("是多少啊=》", zname[0]);

	if (zname) {

		// for (let i = 0; i < zname.length; i++) {
		const res = await nodejs<{ code: number; result: string }>('risk_point/zj-000003/s005', {
			filter: {
				risk_po_type_no: no,
				risk_po_name: risk_po_name1,

				// hidden_source: zname,
				hidden_name: zname
			}
		});

		if (res.code === 1) {
			alert('保存成功');
			window.location.reload();
		} else {
			alert('保存失败');
		}

		// }


	} else {
		const res = await nodejs<{ code: number; result: string }>('risk_point/zj-000003/s004', {
			filter: {
				risk_po_type_no: no,
				risk_po_name: risk_po_name1
			}
		});
		if (res.code === 1) {
			alert('保存成功');
			window.location.reload();
		} else {
			alert('保存失败');
		}
	}
}
